package com.xxx.service.impl;

import com.xxx.dao.DistrictDao;
import com.xxx.pojo.District;
import com.xxx.service.DistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DistrictServiceImpl implements DistrictService {
    @Autowired
    private DistrictDao districtDao;

    @Override
    public List<District> getByParent(String parent) {
        Map<String, Object> map=new HashMap<>();
        map.put("parent",parent);
        List<District> result = districtDao.selectByMap(map);
        /**
         * 把无用的数据设置为null提升传输效率
         */
        for (District district : result) {
            district.setId(null);
            district.setParent(null);
        }
        return result;
    }

}
